<template>
  <div>
    <el-checkbox-group v-model="checkList" v-for="i in rolelist" :key="i.id">
        <el-checkbox :label="i.id">{{i.rname}}</el-checkbox>
    </el-checkbox-group>
    
    <el-button @click="add">用户配置角色</el-button>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    name:'user_role',
    data(){
        return{
            rolelist:[],
            checkList:[],
            uid : localStorage.getItem('uid')
        }
    },
    methods:{
      getrole(){
        axios.get('/rolelist').then(res=>{
          this.rolelist = res.data.list
        })
      },
      add(){
        axios.post('/config_user_role',{'user_id':this.uid,'urlist':this.checkList}).then(res=>{
          console.log(res.data);
        })
      }
    },
    mounted(){
      this.getrole()
    }
}
</script>

<style>

</style>